Sub Main ()
with metascript 
   
   btwndt = " And billdate  between '" & local.dtfrom.tag & "' and '" & local.dtto.tag & "' "
   st = "Select billno, billdate,Code, Name, GSTIN,  error from GIRN_Out  as o, salehead as h, customer as c " & _
      " Where customerkey = customerid and h.billno = DocNo and  mystatus =0 " & BtwnDt
   
   
   set rs = .sumrs(st & "", .getdatafile)
   
   
   
   if not rs.eof then
      if msgbox("Do you want to save to excel?", vbquestion + vbyesno,"Export to excel") = vbyes then
         filename = local.getfilename("enter filename","xls")
         local.dumprstoexcel rs,filename
         msgbox "saved to " & filename
      else
         .showform "Select 0 as s, billno, Code, left(Name,15) as Name, error , salekey from GIRN_Out  as o, salehead as h, customer as c " & _
            " Where customerkey = customerid and h.billno = DocNo and  mystatus =0 " & BtwnDt, .getdatafile, x,y
         
      end if
      
   else
      msgbox "Nothing found"
   end if
   
end with 
End Sub







